package test0927;

import java.util.Objects;

public class Person extends Object{
    private String name;
    private String sex;
    private int age;

    Person(){

    }


    public Person(String name, String sex, int age) {
        super();
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public Person(Person person){
        this.name=person.name;
        this.sex=person.sex;
        this.age=person.age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o instanceof Person){
            Person person = (Person) o;
            if(this.getName().equals(person.getName()) &&
                    this.getAge()==person.getAge() &&
                    this.getSex().equals(person.getSex())){
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, sex, age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                '}';
    }
}
